package entity;

// 子类：Teacher（继承Person父类）
public class Teacher extends Person {
    // 子类特有属性：教授的课程
    private Course taughtCourse;

    // 子类构造方法：调用父类构造方法初始化共性属性
    public Teacher(String teacherId, String teacherName, String gender) {
        super(teacherId, teacherName, gender); // 调用Person父类的构造方法
    }

    // 子类特有方法：设置教授的课程
    public void setTaughtCourse(Course taughtCourse) {
        this.taughtCourse = taughtCourse;
        System.out.println(name + "（教师）成功开设课程：" + taughtCourse.getCourseName());
    }

    // 重写父类方法：打印教师授课信息
    @Override
    public void printInfo() {
        System.out.println("===== 教师授课信息 =====");
        super.printInfo(); // 调用父类方法，打印编号、姓名、性别
        if (taughtCourse != null) {
            System.out.println("教授课程：" + taughtCourse.getCourseName());
            System.out.println("课程编号：" + taughtCourse.getCourseId());
            System.out.println("上课时间：" + taughtCourse.getTime());
            System.out.println("上课地点：" + taughtCourse.getLocation());
        } else {
            System.out.println("教授课程：无");
        }
        System.out.println("======================\n");
    }

    // Getter方法：获取教授的课程
    public Course getTaughtCourse() {
        return taughtCourse;
    }
}